package wangjg.xuexiban.widget;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.widget.EditText;

public class MyDialog {
	public static void showInputDialog(final Context context, final String title, String content, final Callback callback){
		final EditText inputEdit = new EditText(context);
		inputEdit.setText(content);
		inputEdit.setSelection(inputEdit.length());
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setTitle(title).setIcon(android.R.drawable.ic_dialog_info).setView(inputEdit)
        	.setNegativeButton("Cancel", null);
        builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
               String str = inputEdit.getText().toString();
               callback.callback(str);
             }
        });
        builder.show();
	}

	public interface Callback {
		public void callback(String str);
	}
}
